<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sb" uri="/struts-bootstrap-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加管理员</title>
<script type="text/javascript" src="<%=basePath%>js/jquery-2.0.3.min.js"></script>

<script type="text/javascript">
function checkEmail() {
	var adminId=$("#adminId").val();
	var adminEmail=$("#adminEmail").val();
	if(adminEmail==null||adminEmail==""){
		 $("#emailError").text("邮箱不能为空"); 
		}
	var reg=/^[A-Za-zd]+([-_.][A-Za-zd]+)*@([A-Za-zd]+[-.])+[A-Za-zd]{2,5}$/; 
	if(reg.test(adminEmail)){
	$.ajax({
		type:'get',
		url:'admin_checkEmail',
		data:{adminId:adminId,adminEmail:adminEmail},
		dataType:'json',
		 success: function(data){
            //alert(data.msg);
	            $("#emailError").text(data[0].msg);
			 }
		});
	}else{
		 $("#emailError").text("邮箱不合法；");
		}
}
function checkName(){
	var adminId=$("#adminId").val();
	var adminName=$("#adminName").val();
	if(adminName==null||adminName==""){
		 $("#nameError").text("用户名称不能为空");
		}
	$.ajax({
		type:'get',
		url:'admin_checkName',
		data:{adminId:adminId,adminEmail:adminEmail},
		dataType:'json',
		 success: function(data){
            //alert(data.msg);
	            $("#nameError").text(data[0].msg);
			 }
		});
}
function checkPwd(){
	var password=$("#adminPwd").val();
	if(password==null||password==""){
		 $("#passwordError").text("密码不能为空");
		}
	if(password.length>9||password.length<6){
		 $("#passwordError").text("密码长度是6到10位");
		}
}
function checkReplacePwd(){
	var password=$("#adminPwd").val();
    var repalcePwd=$("#replacePwd").val();
    if(password!=repalcePwd){
        $("#replacePwdError").text("两次密码输入不一致");
        }
}
</script>
<sb:head/>
</head>
<body>
<s:form action="admin_adminSave" method="post" theme="simple" id="save">
  <s:hidden name="admin.adminId"  value='%{admin.adminId}' id="adminId"></s:hidden>
  <s:hidden name="admin.status"  value='%{admin.status}' ></s:hidden>
  <s:hidden name="admin.created" value='%{admin.created}'></s:hidden> 
  <s:hidden name="admin.type" value='%{admin.type}'></s:hidden> 
  <div style="width: 500px;height: 180px;background-color: #f0f8ff ;margin: 0px auto;">
<table>
<tr height="40px;">
<td width="120px">注册邮箱<span style="color:red">*</span>：</td>
<td width="150px"><s:textfield name="admin.adminEmail" required="true" style="width:100%;height:100%" theme="simple"  id="adminEmail" onblur="checkEmail()" placeholder="请输入登录邮箱" value="%{admin.adminEmail}"></s:textfield></td>
<td width="200px;" id="emailError"></td>
</tr>
<tr height="40px;">
<td width="120px">注册用户名<span style="color:red">*</span>：</td>
<td width="150px"><s:textfield name="admin.adminName" required="true" style="width:100%;height:100%" theme="simple"  id="adminName" onblur="checkName()"  placeholder="管理员名称" value="%{admin.adminName}"></s:textfield></td>
<td width="200px;"  id="nameError" ></td>
</tr>
<tr height="40px;">
<td width="120px">密码<span style="color:red">*</span>：</td>
<td width="150px"><s:password name="admin.adminPwd" id="adminPwd" style="width:100%;height:100%" theme="simple"  placeholder="请输入登录密码" onblur="checkPwd" required="true" maxlength="8" ></s:password></td>
<td width="200px;" ></td>
</tr>
<tr height="40px;">
<td width="120px">再次输入密码<span style="color:red">*</span>：</td>
<td width="150px"><s:password name="" id="replacePwd" placeholder="请再次输入登录密码" style="width:100%;height:100%" theme="simple"  onblur="checkReplacePwd()" required="true" maxlength="8" ></s:password></td>
<td width="200px;" id="replacePwdError"></td>
</tr>
</table>
</div>
</s:form>
</body>
</html>